package com.kateba.android.blueinput;

import java.io.IOException;
import java.util.ArrayList;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.os.SystemClock;
import android.widget.ImageButton;
import android.widget.Toast;

import com.kateba.android.hid.KBLayout;
import com.kateba.android.utils.CustomAdapter;
import com.kateba.android.utils.DrawView;
import com.kateba.android.utils.ListViewItem;



public class Logic
{
  final String LOG_TAG = "BlueInput::LOGIC";
  GUIBlueinput gui;
  final Runnable mRunUpdateResultsDiscover = new Runnable()
  {
    public void run()
    {
      Logic.this.doneDiscoverBluetoothDevices();
    }
  };
  final Handler m_Handler = new Handler();
  long m_lastTime = 0L;
  int m_nDiscoverResult;
private int j;

  Logic(Context paramContext)
  {
    this.gui = ((GUIBlueinput)paramContext);
  }

  private long GetTime()
  {
    return SystemClock.elapsedRealtime();
  }

  private void Sleep(int paramInt)
  {
    long l = GetTime();
    while (GetTime() - l < paramInt);
  }

  private void doneDiscoverBluetoothDevices()
  {
    if (this.gui.m_progDlg.isShowing())
      this.gui.m_progDlg.dismiss();
    if (this.m_nDiscoverResult == -1)
      MessageToast(2131034163);
    while (true)
    {
      PopulateLV2Available();
      Singleton.getInstance().Debug("BlueInput::LOGIC", "Discovery complete. Code:" + this.m_nDiscoverResult + " Results: " + Singleton.getInstance().m_BTInterf.BTCount);
    //  return;
      if (this.m_nDiscoverResult != 0)
    	  continue;
      MessageToast(2131034164);
    }
  }

  int BTDevId2Index(int paramInt)
  {
    for (int i = 0; ; i++)
    {
      if (i >= Singleton.getInstance().m_BTInterf.BTCount)
        i = -1;
      do
        return i;
      while (Singleton.getInstance().m_BTInterf.BTDevs[i].m_nId == paramInt);
    }
  }

  public boolean CheckBluetooth()
  {
    if (!Singleton.getInstance().m_BTInterf.CheckBluetoothEnabled())
    {
      Intent localIntent = new Intent("android.bluetooth.adapter.action.REQUEST_ENABLE");
      this.gui.startActivityForResult(localIntent, 3);
    }
    for (int i = 0; ; i = 1)
      return i==1?true:false;
  }

  /** @deprecated */
  int ConnectionEvent(int paramInt1, int paramInt2, byte[] paramArrayOfByte)
  {
//    monitorenter;
    while (true)
    {
      try
      {
        int i = Singleton.getInstance().m_BTInterf.BTCount;
        if (paramInt2 < i)
          continue;
        j = -1;
        return j;
        if (paramInt1 != 1)
          continue;
        Singleton.getInstance().Debug("BlueInput::LOGIC", "ConnectionEvent(" + paramInt1 + ") id=" + paramInt2 + " CONNECTED!");
        PopulateLV1Connected();
        PopulateLV2Available();
        if (Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].m_bBTDEVRDValid)
        {
          Singleton.getInstance().Debug("BlueInput::LOGIC", "ConnectionEvent:(CONNECTED) RD Valid");
          if (paramInt1 != 2)
     //       break label379;
          Singleton.getInstance().Debug("BlueInput::LOGIC", "ConnectionEvent(" + paramInt1 + ") id=" + paramInt2 + " DISCONNECTED!");
          Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.poutKBRep.DeinitRep();
          j = Singleton.getInstance().m_BTInterf.Disconnect(paramInt2);
          PopulateLV1Connected();
          PopulateLV2Available();
          if (j != 0)
           // break label324;
          MessageToast(this.gui.getResources().getString(2131034169) + " " + Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].m_szName);
          continue;
        }
      }
      finally
      {
//        monitorexit;
      }
      Singleton.getInstance().Debug("BlueInput::LOGIC", "ConnectionEvent:(CONNECTED) RD Invalid, put device in BOOT MODE");
      byte[] arrayOfByte = new byte[1];
      arrayOfByte[0] = 112;
      Singleton.getInstance().Debug("BlueInput::LOGIC", "ConnectionEvent:(CONNECTED) SET_PROTOCOL (0x70) ASDK BT");
      try
      {
        Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].m_btsckCTRL.getOutputStream().write(arrayOfByte);
      }
      catch (IOException localIOException)
      {
        localIOException.printStackTrace();
      }
      //continue;
      //label324:
    	  MessageToast(this.gui.getResources().getString(2131034170) + " " + Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].m_szName);
      //continue;
     // label379:
    	  int i3;
      if (paramInt1 == 3)
      {
        Singleton.getInstance().Debug("BlueInput::LOGIC", "ConnectionEvent(" + paramInt1 + ") id=" + paramInt2 + " Name=[" + Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].m_szName + "] HidReport(" + paramArrayOfByte.length + ") ");
        if (paramArrayOfByte.length == 0)
        {
          j = -1;
          continue;
        }
        int i1 = 0xFF & paramArrayOfByte[0];
        int i2 = 0xF & i1 >>> 4;
        i3 = i1 & 0xF;
        switch (i2)
        {
        case 11:
        default:
        case 1:
        case 10:
        }
      }
      //label687:
    	  String str;
      int i9;
      //label707: 
      do
      {
        do
          while (true)
          {
            if (paramInt1 != 4)
              break label1534;
            Singleton.getInstance().Debug("BlueInput::LOGIC", "ConnectionEvent(" + paramInt1 + ") CTRL Devid=" + paramInt2 + " Name=[" + Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].m_szName + "] Data(" + paramArrayOfByte.length + ") ");
            if (paramArrayOfByte.length != 0)
              break label1449;
            j = -1;
            break;
            if (i3 != 5)
              continue;
            Singleton.getInstance().Debug("BlueInput::LOGIC", "*** ConnectionEvent VIRTUAL_CABLE_UNPLUG, Disconnected will follow.");
          }
        while (i3 != 1);
        if (!Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].m_bBTDEVRDValid)
          break label1337;
        Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.ParseReport(paramArrayOfByte, paramArrayOfByte.length);
        if (Singleton.getInstance().m_sett.getDebug())
        {
          str = "";
          i9 = 0;
          if (i9 < Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.KB_BufSize)
            break label1395;
          Singleton.getInstance().Debug("BlueInput::LOGIC", "*** ConnectionEvent parsed ACTION: RDValid=" + Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].m_bBTDEVRDValid + " Devtype=" + Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.DevType + " KB_Modifier=" + Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.KB_Modifier + " KB_BufSize=" + Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.KB_BufSize + " KB_BufKeys=[" + str + "]" + " Mouse_Buts=" + Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.Mouse_Buts + " Mouse_X=" + Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.Mouse_X + " Mouse_Y=" + Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.Mouse_Y + " Mouse_Wheel=" + Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.Mouse_Wheel);
        }
        if (((Singleton.getInstance().m_vkInst == null) || (!Singleton.getInstance().m_vkInst.m_bVKReady)) && (Singleton.getInstance().m_sett.getHints()) && (!TooEarly(2000L)))
          MessageToast(2131034115);
        Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.DOHIDACTION();
      }
      while (this.gui.m_panelGFX == null);
      int i4 = Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.Mouse_X;
      int i5 = Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.Mouse_Y;
      if (Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.Mouse_Buts == 1);
      for (boolean bool = true; ; bool = false)
      {
        DrawView localDrawView1 = this.gui.m_panelGFX;
        //3 
        local3 = new Runnable(i4, i5, bool)
        {
          public void run()
          {
            Logic.this.gui.m_panelGFX.UpdateCursor(this.val$dx, this.val$dy, this.val$leftbut);
          }
        };
        localDrawView1.post(local3);
        if (Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.Mouse_Buts == 2)
        {
          DrawView localDrawView3 = this.gui.m_panelGFX;
          //4 
          local4 = new Runnable()
          {
            public void run()
            {
              Logic.this.gui.m_panelGFX.Clear();
            }
          };
          localDrawView3.post(local4);
        }
        int i6;
        while (i6 < Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.KB_BufSize)
        {
          int i7 = (char)Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.KB_BufKeys[i6];
          //label1337: label1395:
        	  int m;
          //label1449:
        	  int n;
          if (i7 != 0)
          {
            int i8 = KBLayout.GetAndroidKeySymbol(i7);
            if (i8 == 0)
              i8 = 36;
            char c = (char)i8;
            DrawView localDrawView2 = this.gui.m_panelGFX;
            //5
            local5 = new Runnable(c)
            {
              public void run()
              {
                Logic.this.gui.m_panelGFX.AddKey(this.val$key);
              }
            };
            localDrawView2.post(local5);
            break label1522;
            Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.DevType = Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].m_nBTDEVType;
            Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.ParseBootReport(paramArrayOfByte, paramArrayOfByte.length);
            break label687;
            str = str + " " + Singleton.getInstance().m_BTInterf.BTDevs[paramInt2].HidParserObj.poutAction.KB_BufKeys[i9];
            i9++;
            break label707;
            int k = 0xFF & paramArrayOfByte[0];
            m = 0xF & k >>> 4;
            n = k & 0xF;
          }
          switch (m)
          {
          case 10:
            if (n != 1)
              break label1534;
            Singleton.getInstance().Debug("BlueInput::LOGIC", "CTRL Data input report.");
            break label1534;
            i6 = 0;
            continue;
            label1522: i6++;
          }
        }
      }
      //label1534:
    	  int j = 0;
    }
  }

  int ListItemConnect(int paramInt)
  {
    int i = Singleton.getInstance().m_BTInterf.Connect(paramInt);
    Singleton.getInstance().Debug("BlueInput::LOGIC", "Connect to (" + Singleton.getInstance().m_BTInterf.BTDevs[paramInt].m_szName + ") res=" + i + " (0=SUCCESS)");
    if (i == 0)
    {
      StartReadThreadINTR(paramInt);
      StartReadThreadCTRL(paramInt);
    }
    return i;
  }

  boolean ListItemDisconnect(int paramInt)
  {
    if (ConnectionEvent(2, paramInt, null) == 0);
    for (int i = 1; ; i = 0)
      return i==1?true:false;
  }

  public void MessageBox(String paramString1, String paramString2)
  {
    if (paramString1 == null)
      paramString1 = this.gui.getResources().getString(2131034113);
    new AlertDialog.Builder(this.gui).setIcon(this.gui.getResources().getDrawable(2130837505)).setTitle(paramString1).setMessage(paramString2).setCancelable(false).setPositiveButton(this.gui.getResources().getString(17039370), new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramDialogInterface, int paramInt)
      {
        paramDialogInterface.cancel();
      }
    }).show();
  }

  public void MessageToast(int paramInt)
  {
    MessageToast(this.gui.getResources().getString(paramInt));
  }

  public void MessageToast(String paramString)
  {
    this.m_Handler.post(new Runnable(paramString)
    {
      public void run()
      {
        Toast.makeText(Logic.this.gui, this.val$message, 1).show();
      }
    });
  }

  public void PopulateBluetooth()
  {
    boolean bool = Singleton.getInstance().m_BTInterf.CheckBluetoothEnabled();
    ImageButton localImageButton = (ImageButton)this.gui.findViewById(106);
    if (localImageButton != null)
      localImageButton.post(new Runnable(bool, localImageButton)
      {
        public void run()
        {
          if (this.val$state)
            this.val$img.setImageDrawable(Logic.this.gui.getResources().getDrawable(2130837522));
          while (true)
          {
     //       return;
            this.val$img.setImageDrawable(Logic.this.gui.getResources().getDrawable(2130837521));
          }
        }
      });
  }

  public int PopulateCapsLock(boolean paramBoolean)
  {
    ImageButton localImageButton = (ImageButton)this.gui.findViewById(104);
    if (localImageButton != null)
      localImageButton.post(new Runnable(paramBoolean, localImageButton)
      {
        public void run()
        {
          if (this.val$state)
            this.val$img.setImageDrawable(Logic.this.gui.getResources().getDrawable(2130837524));
          while (true)
          {
   //         return;
            this.val$img.setImageDrawable(Logic.this.gui.getResources().getDrawable(2130837523));
          }
        }
      });
    return 0;
  }

  void PopulateLV1Connected()
  {
    this.gui.m_lv1Connected.post(new Runnable()
    {
      public void run()
      {
        Singleton.getInstance().Debug("BlueInput::LOGIC", "PopulateLV1Connected call.");
        ArrayList localArrayList = new ArrayList();
        for (int i = 0; ; i++)
        {
          if (i >= Singleton.getInstance().m_BTInterf.BTCount)
          {
            CustomAdapter localCustomAdapter = new CustomAdapter(Logic.this.gui, localArrayList);
            if (Logic.this.gui.m_lv1Connected != null)
              Logic.this.gui.m_lv1Connected.setAdapter(localCustomAdapter);
            return;
          }
          Singleton.getInstance().Debug("BlueInput::LOGIC", "PopulateLV1Connected(" + i + ") name=" + Singleton.getInstance().m_BTInterf.BTDevs[i].m_szName + " Sockets(Native):" + Singleton.getInstance().m_BTInterf.BTDevs[i].m_nL2CAPSockCTRL + "/" + Singleton.getInstance().m_BTInterf.BTDevs[i].m_nL2CAPSockINTR + " Sockets(ASDK):" + Singleton.getInstance().m_BTInterf.BTDevs[i].m_btsckCTRL + "/" + Singleton.getInstance().m_BTInterf.BTDevs[i].m_btsckINTR);
          if (!Singleton.getInstance().m_BTInterf.BTDevs[i].isConnected())
            continue;
          localArrayList.add(new ListViewItem(Singleton.getInstance().m_BTInterf.BTDevs[i].m_szName, Singleton.getInstance().m_BTInterf.BTDevs[i].m_szAddress, Singleton.getInstance().m_BTInterf.BTDevs[i].m_nBTDEVType, true, i + 1001));
        }
      }
    });
  }

  void PopulateLV2Available()
  {
    this.gui.m_lv2Available.post(new Runnable()
    {
      public void run()
      {
        Singleton.getInstance().Debug("BlueInput::LOGIC", "PopulateLV2Available call " + Singleton.getInstance().m_BTInterf.BTCount + " devs.");
        ArrayList localArrayList;
        if (Singleton.getInstance().m_BTInterf.BTCount > 0)
          localArrayList = new ArrayList();
        for (int i = 0; ; i++)
        {
          if (i >= Singleton.getInstance().m_BTInterf.BTCount)
          {
            CustomAdapter localCustomAdapter = new CustomAdapter(Logic.this.gui, localArrayList);
            if (Logic.this.gui.m_lv2Available != null)
              Logic.this.gui.m_lv2Available.setAdapter(localCustomAdapter);
            return;
          }
          Singleton.getInstance().Debug("BlueInput::LOGIC", "PopulateLV2Available(" + i + ") name=" + Singleton.getInstance().m_BTInterf.BTDevs[i].m_szName + " " + Singleton.getInstance().m_BTInterf.BTDevs[i].m_szAddress + " Type=" + Singleton.getInstance().m_BTInterf.BTDevs[i].m_nBTDEVType);
          localArrayList.add(new ListViewItem(Singleton.getInstance().m_BTInterf.BTDevs[i].m_szName, Singleton.getInstance().m_BTInterf.BTDevs[i].m_szAddress, Singleton.getInstance().m_BTInterf.BTDevs[i].m_nBTDEVType, Singleton.getInstance().m_BTInterf.BTDevs[i].isConnected(), i + 2001));
        }
      }
    });
  }

  public int PopulateNumLock(boolean paramBoolean)
  {
    ImageButton localImageButton = (ImageButton)this.gui.findViewById(105);
    if (localImageButton != null)
      localImageButton.post(new Runnable(paramBoolean, localImageButton)
      {
        public void run()
        {
          if (this.val$state)
            this.val$img.setImageDrawable(Logic.this.gui.getResources().getDrawable(2130837526));
          while (true)
          {
 //           return;
            this.val$img.setImageDrawable(Logic.this.gui.getResources().getDrawable(2130837525));
          }
        }
      });
    return 0;
  }

  public void StartActivity(int paramInt)
  {
    Intent localIntent1 = null;
    switch (paramInt)
    {
    default:
    case 1:
    case 2:
    case 3:
    case 4:
    }
    while (true)
    {
      this.gui.startActivity(localIntent1);
    //  return;
      localIntent1 = new Intent("android.intent.action.MAIN");
      localIntent1.addCategory("android.intent.category.HOME");
      localIntent1.setFlags(268435456);
      //continue;
      localIntent1 = new Intent("android.intent.action.VIEW", Uri.parse("http://www.teksoftco.com/index.php?section=product&pid=24#view"));
      //continue;
      Intent localIntent2 = new Intent("android.intent.action.SEND");
      localIntent2.setType("text/plain");
      localIntent2.putExtra("android.intent.extra.SUBJECT", this.gui.getResources().getString(2131034126));
      localIntent2.putExtra("android.intent.extra.TEXT", "http://www.teksoftco.com/index.php?section=product&pid=24#view");
      localIntent1 = Intent.createChooser(localIntent2, this.gui.getResources().getString(2131034125));
      //continue;
      localIntent1 = new Intent("android.intent.action.VIEW", Uri.parse("http://www.facebook.com/Teksoft.Software"));
    }
  }

  /** @deprecated */
  int StartReadThreadCTRL(int paramInt)
  {
    monitorenter;
    try
    {
      Singleton.getInstance().Debug("BlueInput::LOGIC", "StartReadThreadCTRL called.");
      Singleton.getInstance().m_BTInterf.BTDevs[paramInt].m_hReadThreadCTRL = new Thread(paramInt)
      {
        public void run()
        {
          while (true)
          {
            byte[] arrayOfByte1 = (byte[])null;
            int i = 0;
            try
            {
              if (Singleton.getInstance().m_BTInterf.BTDevs[this.val$nIndex].m_btsckCTRL != null)
              {
                byte[] arrayOfByte2 = new byte[1024];
                i = Singleton.getInstance().m_BTInterf.BTDevs[this.val$nIndex].m_btsckCTRL.getInputStream().read(arrayOfByte2);
                arrayOfByte1 = new byte[i];
                System.arraycopy(arrayOfByte2, 0, arrayOfByte1, 0, i);
              }
              Object localObject;
              if (Singleton.getInstance().m_sett.getDebug())
                localObject = new String();
              for (int j = 0; ; j++)
              {
                if (j >= i)
                {
                  Singleton.getInstance().Debug(0, "BlueInput::LOGIC", "StartReadThreadCTRL:" + i + "B:" + (String)localObject);
                  if (arrayOfByte1 != null)
                    break;
                  Singleton.getInstance().Debug("BlueInput::LOGIC", "StartReadThreadCTRL: thread finished.");
                  return;
                }
                String str = localObject + " 0x" + Integer.toHexString(0xFF & arrayOfByte1[j]).toUpperCase();
                localObject = str;
              }
            }
            catch (IOException localIOException)
            {
              do
                while (true)
                  Singleton.getInstance().Debug("BlueInput::LOGIC", "StartReadThreadCTRL: disconnected:" + localIOException.getMessage());
              while (arrayOfByte1.length == 0);
              Logic.this.ConnectionEvent(4, this.val$nIndex, arrayOfByte1);
            }
          }
        }
      };
      Singleton.getInstance().m_BTInterf.BTDevs[paramInt].m_hReadThreadCTRL.start();
      monitorexit;
      return 0;
    }
    finally
    {
      localObject = finally;
      monitorexit;
    }
    throw localObject;
  }

  /** @deprecated */
  int StartReadThreadINTR(int paramInt)
  {
    monitorenter;
    try
    {
      Singleton.getInstance().Debug("BlueInput::LOGIC", "StartReadThreadINTR called.");
      ConnectionEvent(1, paramInt, null);
      Singleton.getInstance().m_BTInterf.BTDevs[paramInt].m_hReadThreadINTR = new Thread(paramInt)
      {
        public void run()
        {
          while (true)
          {
            byte[] arrayOfByte1 = (byte[])null;
            try
            {
              if (Singleton.getInstance().m_BTInterf.BTDevs[this.val$nIndex].m_btsckINTR != null)
              {
                byte[] arrayOfByte2 = new byte[1024];
                int j = Singleton.getInstance().m_BTInterf.BTDevs[this.val$nIndex].m_btsckINTR.getInputStream().read(arrayOfByte2);
                arrayOfByte1 = new byte[j];
                System.arraycopy(arrayOfByte2, 0, arrayOfByte1, 0, j);
              }
              if ((Singleton.getInstance().m_sett.getDebug()) && (arrayOfByte1 != null))
              {
                str = new String();
                i = 0;
                if (i >= arrayOfByte1.length)
                  Singleton.getInstance().Debug(0, "BlueInput::LOGIC", "StartReadThreadINTR:" + arrayOfByte1.length + "B:" + str);
              }
              else
              {
                if (arrayOfByte1 != null)
                  break label250;
                Logic.this.ConnectionEvent(2, this.val$nIndex, null);
                Singleton.getInstance().Debug("BlueInput::LOGIC", "StartReadThreadINTR: thread finished.");
                return;
              }
            }
            catch (IOException localIOException)
            {
              while (true)
              {
                int i;
                Singleton.getInstance().Debug("BlueInput::LOGIC", "StartReadThreadINTR: disconnected:" + localIOException.getMessage());
                continue;
                String str = str + " 0x" + Integer.toHexString(0xFF & arrayOfByte1[i]).toUpperCase();
                i++;
                continue;
                label250: if (arrayOfByte1.length != 0)
                  break;
                Logic.this.ConnectionEvent(2, this.val$nIndex, null);
              }
              Logic.this.ConnectionEvent(3, this.val$nIndex, arrayOfByte1);
            }
          }
        }
      };
      Singleton.getInstance().m_BTInterf.BTDevs[paramInt].m_hReadThreadINTR.start();
      monitorexit;
      return 0;
    }
    finally
    {
      localObject = finally;
      monitorexit;
    }
    throw localObject;
  }

  boolean TooEarly(long paramLong)
  {
    long l = GetTime();
    if (l - this.m_lastTime < paramLong)
      this.m_lastTime = l;
    for (int i = 1; ; i = 0)
    {
      return i;
      this.m_lastTime = l;
    }
  }

  protected void startDiscoverBluetoothDevices()
  {
    Singleton.getInstance().Debug("BlueInput::LOGIC", "startDiscoverBluetoothDevices call.");
    this.gui.m_progDlg = ProgressDialog.show(this.gui, this.gui.getResources().getString(2131034113), this.gui.getResources().getString(2131034162), true);
    new Thread()
    {
      public void run()
      {
        Logic.this.m_nDiscoverResult = Singleton.getInstance().m_BTInterf.DiscoverBluetoothDevices();
        Logic.this.m_Handler.post(Logic.this.mRunUpdateResultsDiscover);
      }
    }
    .start();
  }
}